package com.example.controller;

import com.example.consts.RbmConsts;
import com.example.pojo.dto.BossDTO;
import com.example.pojo.entity.JobRecruiter;
import com.example.pojo.entity.Post;
import com.example.service.PostService;
import com.example.service.RecruiterService;
import com.example.vo.Result;
import com.oracle.wls.shaded.org.apache.xpath.SourceTree;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 小岁
 * @version 2023/10/5 22:06
 */

@RestController
@RequestMapping("Details")
public class JobDetailsController {
    @Autowired
    private RecruiterService recruiterService;

    @Autowired
    private PostService postService;

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("{recruiterId}")
    public Result getByRecruiterId(@PathVariable Integer recruiterId){

        JobRecruiter jobRecruiter = recruiterService.findByRecruiterId(recruiterId);

        return new Result(200,"success",jobRecruiter);
    }
    @GetMapping("postId/{postId}")
    public Result getPostId(@PathVariable("postId") Integer postId){
        System.out.println("=postId=");
        System.out.println(postId);

        BossDTO bossDTO = postService.findById(postId);


//        Post post = postService.findByPostId(postId);

        return new Result(200,"success",bossDTO);
    }
    @GetMapping("jrId/{jrId}")
    public Result getJrId(@PathVariable("jrId") Integer id){
        System.out.println("==Details==");
//        List<Post> bossDTO = postService.findByJrId(jrId);
        BossDTO bossDTO = postService.findByRId(id);
        System.out.println("==Details==");
        System.out.println(bossDTO);
        return new Result(200,"success",bossDTO);

    }
    @GetMapping("jrById/{jrId}")
    public Result getByJrId(@PathVariable("jrId") Integer jrId){
        List<Post> post = postService.findByJrId(jrId);

        return new Result(200,"success",post);
    }

    @GetMapping("Count/{jrId}")
    public Result getCountByJrId(@PathVariable("jrId") Integer jrId){
        Integer count = postService.contByJrId(jrId);
        return new Result(200,"success",count);
    }

    @PostMapping("Find")
    public Result getByPosName(String posName,Integer jrId){
        List<Post> postList = postService.findByPosName(posName,jrId);
        return new Result(200,"success",postList);

    }

    @GetMapping("findAll")
    public Result findAlls(){
        List<Post> postList = postService.findAlls();
        System.out.println(postList);
        return new Result(200,"success",postList);
    }
}
